//
//  LoginRegisterCountryCell.swift
//  GLUZSwift
//
//  Created by xyanl on 2025/3/7.
//  Copyright © 2025 考拉🐨. All rights reserved.
//

import UIKit
import Reusable
import Localize_Swift

extension LoginRegisterCountryCell: NibReusable {}

class LoginRegisterCountryCell: UICollectionViewCell {

    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    
    var model: AreaCodeModel? {
        didSet {
            guard let model = model else { return }
            
            iconImageView.image = model.image.toImage
            nameLabel.text = model.name.localized()
            
            if model.isSelected {
                addRoundedCorners(radius: 10, width: 1, color: UIColor(hex: "#278AFF"))
                contentView.backgroundColor = UIColor(hex: "#D7E9FF")
                nameLabel.textColor = UIColor(hex: "#278AFF")
            } else {
                addRoundedCorners(radius: 10, width: 1, color: .clear)
                contentView.backgroundColor = UIColor(hex: "#F7F7F7")
                nameLabel.textColor = UIColor(hex: "#0E0E0E")
            }
            
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        addRoundedCorners(radius: 10, width: 1, color: .clear)
        contentView.backgroundColor = UIColor(hex: "#F7F7F7")
        nameLabel.textColor = UIColor(hex: "#0E0E0E")
    }

}
